<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>2.3.4函数参数的解构赋值</title>
    </head>
    <body>
        <script>
            //【2.21】函数参数解构赋值
            function add([x,y]){
                return x + y;
            }
            let result=add([1,2]);
            console.log(result);

            //【2.22】函数参数解构赋值使用默认值
            function move({x=0,y=0}={}){
                return [x,y];
            }
            console.log(move({x:3,y:8}));//[3,8]
            console.log(move({x:3}));//[3,0]
            console.log(move({}));//[0,0]
            console.log(move());//[0,0]
        </script>
    </body>
</html>